package com.qfjy.controller.example1;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("account")
@Controller
@Slf4j
public class AccountController {

    /**
     消息队列 模版   RedisTemplate
     */
    @Autowired
    private AmqpTemplate amqpTemplate;

    /**
     * 发放薪资的业务方法
     * @return
     */
    @GetMapping("sendWage")
     @ResponseBody
     public String sendWage(HttpServletRequest request){

         String cardId=request.getParameter("cardId");
         //调用 AccountService进行工资转帐transfer.....
        log.info("卡号这个薪资发放完毕---》{}",cardId);

        /**
         * String var1, Object var2
         * @param1: 队列的名称
         * @param2: 数据传输的截体（底层二进制传输）
         *
         */
        amqpTemplate.convertAndSend("emailQueue",cardId);

         return "工资发放成功"+cardId;
     }
}
